<!---
Copyright (c) 2007 Brian Billman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
--->
<cfcomponent displayname="CFSmugConfig" output="false">

	<cfproperty name="APIKey" required="true" type="string" displayname="APIKey" hint="To use SmugMug's API, you need an API key. Each individual application or use of the API should use its own key." />
	<cfproperty name="UserAgent" required="true" type="string" displayname="UserAgent" hint="User Agent to report to SmugMug" />
	<cfproperty name="PreferSecureMode" required="false" type="boolean" default="false" displayname="PreferSecureMode" hint="If true, all requests sent to SmugMug will be over HTTPS. By default, only requests that deal with authentication or contain passwords will be over HTTPS." />
	<cfproperty name="DebugEnabled" required="false" type="boolean" default="false" displayname="DebugEnabled" hint="If true, CFSmug calls will be logged." />
	<cfproperty name="DebugLogFileName" required="false" type="string" default="cfsmug" displayname="DebugLogFileName" hint="When DebugEnabled is set to true, the filename that the debugging statements will log to." />
	<cfproperty name="SmugMugRequestTimeout" required="false" type="numeric" default="180" displayname="SmugMugRequestTimeout" hint="Number of seconds until a request to SmugMug will timeout." />
	<cfproperty name="SmugMugUploadTimeout" required="false" type="numeric" default="600" displayname="SmugMugUploadTimeout" hint="Number of seconds until an upload to SmugMug will timeout." />
	<cfproperty name="PageEncoding" required="false" type="string" displayname="PageEncoding" default="iso-8859-1" hint="Used to convert the binary data of an uploaded image to a string in order to calculate its MD5 hash value. Do not change unless you have problems uploading." />

	<cffunction name="init" access="public" output="false" returntype="CFSmugConfig">
		<cfargument name="APIKey" type="string" required="true" hint="API Key of the application" />
		<cfargument name="UserAgent" type="string" required="true" hint="User Agent to report to SmugMug" />
		<cfargument name="PreferSecureMode" type="boolean" required="false" default="false" hint="If true, all requests sent to SmugMug will be over HTTPS. By default, only requests that deal with authentication or contain passwords will be over HTTPS." />
		<cfargument name="DebugEnabled" type="boolean" required="false" default="false" hint="If true, CFSmug calls will be logged." />
		<cfargument name="DebugLogFileName" type="string" required="false" default="cfsmug" hint="When DebugEnabled is set to true, the filename that the debugging statements will log to." />
		<cfargument name="SmugMugRequestTimeout" type="numeric" required="false" default="180" hint="Number of seconds until a request to SmugMug will timeout." />
		<cfargument name="SmugMugUploadTimeout" type="numeric" required="false" default="600" hint="Number of seconds until an upload to SmugMug will timeout." />
		<cfargument name="PageEncoding" type="string" required="false" default="iso-8859-1" hint="Used to convert the binary data of an uploaded image to a string in order to calculate its MD5 hash value. Do not change unless you have problems uploading." />

		<cfset Variables.properties = StructNew() />

		<cfset setUserAgent( Trim( Arguments.UserAgent ) ) />
		<cfset setAPIKey( Arguments.APIKey ) />
		<cfset setPreferSecureMode( Arguments.PreferSecureMode ) />
		<cfset setDebugEnabled( Arguments.DebugEnabled ) />
		<cfset setDebugLogFileName( Arguments.DebugLogFileName ) />
		<cfset setSmugMugRequestTimeout( Arguments.SmugMugRequestTimeout ) />
		<cfset setSmugMugUploadTimeout( Arguments.SmugMugUploadTimeout ) />
		<cfset setPageEncoding( trim( Arguments.pageEncoding ) ) />

		<cfreturn this />
	</cffunction>

	<cffunction name="getAPIKey" access="public" output="false" returntype="string">
		<cfreturn Variables.properties.APIKey />
	</cffunction>

	<cffunction name="setAPIKey" access="public" output="false" returntype="void">
		<cfargument name="APIKey" type="string" required="true" />
		<cfset Variables.properties.APIKey = arguments.APIKey />
		<cfreturn />
	</cffunction>

	<cffunction name="setUserAgent" access="public" output="false" returntype="void">
		<cfargument name="UserAgent" type="string" required="true" />
		<cfset Variables.properties.UserAgent = arguments.UserAgent />
		<cfreturn />
	</cffunction>

	<cffunction name="getUserAgent" access="public" output="false" returntype="string">
		<cfreturn Variables.properties.UserAgent />
	</cffunction>

	<cffunction name="setPreferSecureMode" access="public" output="false" returntype="void">
		<cfargument name="PreferSecureMode" type="boolean" required="true" />
		<cfset Variables.properties.PreferSecureMode = arguments.PreferSecureMode />
		<cfreturn />
	</cffunction>

	<cffunction name="isPreferSecureMode" access="public" output="false" returntype="boolean">
		<cfreturn Variables.properties.PreferSecureMode />
	</cffunction>

	<cffunction name="isDebugEnabled" access="public" output="false" returntype="boolean">
		<cfreturn Variables.properties.DebugEnabled />
	</cffunction>

	<cffunction name="setDebugEnabled" access="public" output="false" returntype="void">
		<cfargument name="DebugEnabled" type="boolean" required="true" />
		<cfset Variables.properties.DebugEnabled = Arguments.DebugEnabled />
	</cffunction>

	<cffunction name="getDebugLogFileName" access="public" output="false" returntype="string">
		<cfreturn Variables.properties.DebugLogFileName />
	</cffunction>

	<cffunction name="setDebugLogFileName" access="public" output="false" returntype="void">
		<cfargument name="DebugLogFileName" type="string" required="true" />
		<cfset Variables.properties.DebugLogFileName = Arguments.DebugLogFileName />
	</cffunction>

	<cffunction name="getSmugMugRequestTimeout" access="public" output="false" returntype="numeric">
		<cfreturn Variables.properties.SmugMugRequestTimeout />
	</cffunction>

	<cffunction name="setSmugMugRequestTimeout" access="public" output="false" returntype="void">
		<cfargument name="SmugMugRequestTimeout" type="numeric" required="true" hint="Number of seconds until a request to SmugMug will timeout." />
		<cfset Variables.properties.SmugMugRequestTimeout = arguments.SmugMugRequestTimeout />
		<cfreturn />
	</cffunction>

	<cffunction name="getSmugMugUploadTimeout" access="public" output="false" returntype="numeric">
		<cfreturn Variables.properties.SmugMugUploadTimeout />
	</cffunction>

	<cffunction name="setSmugMugUploadTimeout" access="public" output="false" returntype="void">
		<cfargument name="SmugMugUploadTimeout" type="numeric" required="true" hint="Number of seconds until an upload to SmugMug will timeout." />
		<cfset Variables.properties.SmugMugUploadTimeout = arguments.SmugMugUploadTimeout />
		<cfreturn />
	</cffunction>

	<cffunction name="getPageEncoding" access="public" output="false" returntype="string">
		<cfreturn Variables.properties.PageEncoding />
	</cffunction>

	<cffunction name="setPageEncoding" access="public" output="false" returntype="void">
		<cfargument name="PageEncoding" type="string" required="true" />
		<cfset Variables.properties.PageEncoding = arguments.PageEncoding />
		<cfreturn />
	</cffunction>

	<cffunction name="getProperties" access="public" output="false" returntype="struct">
		<cfreturn Variables.properties />
	</cffunction>

</cfcomponent>